using System;
using UnityEngine;
using QFramework;

namespace Survivor
{
	public partial class SimpleAbility : ViewController
	{
		private float currentSeconed;

		private void Update()
		{
			currentSeconed += Time.deltaTime;
			if (currentSeconed > Global.SimpleAbilityDuration.Value)
			{
				currentSeconed = 0;

				var enemies = FindObjectsOfType<Enemy>();
				foreach (var enemy in enemies)
				{
					var distance = (Player.Instance.transform.position - enemy.transform.position).magnitude;
					if (distance < 5f)
					{
						enemy.Hurt(Global.SimpleAbilityDamage.Value);
					}
				}
			}

		}
	}
}
